import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema, Types } from 'mongoose';

export type QuestionDocument = Question & Document;

// 定义选项接口
export interface QuestionOption {
  label: string;
  content: string;
}

@Schema()
export class Question extends Document {

  @Prop({ required: true })
  content: string;

  @Prop({ type: [{ label: String, content: String }] })
  options: QuestionOption[];

  @Prop({
    required: true,
    enum: ['single', 'multiple', 'judge'],
    default: 'single',
  })
  type: string;

  @Prop({
    required: true,
    enum: ['行政职业能力测试', '公安专业知识', '申论'],
    default: '行政职业能力测试', // Adding a default value
  })
  category: string;

  @Prop({ type: [String] }) // 修改为字符串数组，存储选项标签如 "A", "B" 等
  correctAnswer: string[];

  @Prop([String])
  imageUrls: string[];

  @Prop({ default: 1 })
  score: number;
}

export const QuestionSchema = SchemaFactory.createForClass(Question);